<?php require_once "menu.php"; ?>
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="menudottedline" width="40%"><div class="pathway"></div></td>
        <td class="menudottedline" align="right">
            <table cellpadding="0" cellspacing="0" border="0" id="toolbar">
                <tr height="60" valign="middle" align="center">
                    <td>
                        <a class="toolbar" href="#">
                        <?php echo $html->image('admin/help_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Help
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<br>
<br>
<div align="center" class="centermain">
    <div class="main">

        <table class="adminheading">
            <tr>
                <th class="info" rowspan="2" nowrap>Manage Extras</th>
            </tr>
        </table>

        <form id="adminForm" name="adminForm" method="post" action="">
        <input type="hidden" id="flag" name="data[flag]" />
        <table class="adminform">
            <tr>
                <td width="80%" valign="top">
                    <table width="100%">
                        <tr>
                            <td width="50%" valign="top" style="padding: 0px;">
                                <table class="adminlist" cellpadding="20">
                                    <tr>
                                        <th colspan="2">Items</th>
                                        <th width="40%" align="right">Show Records:&nbsp;<?php echo $form->select('limit', array('20' => '20', '50' => '50', '100' => '100'), $limit, array('onchange' => 'this.form.submit();')); ?></th>
                                    </tr>
                                    <tr bgcolor="#ae1d1d">
                                        <td width="20%" class="subheader" align="left"><?php echo $paginator->sort('Extra#', 'extrasId', array('style' => 'color: #ffffff;')); ?></td>
                                        <td width="%" class="subheader" align="left"><?php echo $paginator->sort('Type', 'etype', array('style' => 'color: #ffffff;')); ?></td>
                                        <td width="15%" class="subheader" align="left">&nbsp;</td>
                                    </tr>

                                    <?php
                                     if ($etypes) {
                                       foreach($etypes as $k => $v){
                                            $color = (($k/2) == round($k/2)) ? "#efefef" : "#ffffff";
                                            if ($v['Extra']['etype']) {
                                     ?>
                                    <tr bgcolor="<?php echo $color; ?>" style="height: 30px;">
                                        <td>&nbsp;&nbsp;<?php echo $v['Extra']['extrasId']; ?></td>
                                        <td><?php echo $v['Extra']['etype']; ?></td>
                                        <td align="right" style="padding-right: 25px;"><?php echo $html->link('Modify', '/extra/extramgnt/modify/'.urlencode($v['Extra']['etype'])); ?></td>
                                    </tr>
                                   <?php
                                            }
                                       }
                                     }
                                     ?>
                                    <tr>
                                        <td colspan="4" align="center">
                                            <div class="pagination">
                                                <?php
                                                echo $paginator->prev()."&nbsp;";
                                                echo $paginator->numbers();
                                                echo "&nbsp;".$paginator->next();
                                                ?>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="50%" valign="top" style="padding: 0px;">
                                <table class="adminlist" cellpadding="20">
                                    <tr bgcolor="#ae1d1d">
                                        <td class="subheader" colspan="2">Extras Value</td>
                                    </tr>

                                    <!-- search results -->
                                    <?php
                                     if ($results) {
                                         foreach ($results as $v) {
                                     ?>
                                    <tr>
                                        <td width="20%"><?php echo $v['Extra']['etype']; ?></td>
                                        <td width="60%" align="center">
                                            <input type="text" name="data[extras][value][]" value="<?php echo $v['Extra']['value'] ?>" style="width: 95%;" />
                                            <input type="hidden" name="data[extras][extrasid][]" value="<?php echo $v['Extra']['extrasId']; ?>" />
                                        </td>

                                   <?php
                                         }
                                    ?>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td align="left">
                                            <input type="button" value="Update" id="update_btn" class="button" style="width: 40%;" />
                                        </td>
                                    </tr>
                                   <?php
                                     }
                                     ?>

                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="20%" valign="top">
                    <table class="adminlist" cellpadding=20>
            		</table>
                    <table class="adminlist">
                        <tr>
                            <th>Search</th>
                        </tr>
                        <tr>
                            <td><input type="text" name="data[search][subject]" value="<?php echo (isset($search_str))?$search_str:"";   ?>" style="width: 95%" /></td>
                        </tr>
                        <tr>
                            <td colspan="2"><input type="button" id="search_btn" value="Search" class="button" style="width: 100%;" /></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <input type="hidden" name="boxchecked" value="0">
        <input type="hidden" id="ticketId" name="data[extraId]">
        </form>

    </div>
</div>

<script type="text/javascript">
function checkAllId()
{
    var num = "<?php echo $cnt; ?>";
    checkAll(num, 'nt', 'toggle1');
}

function checkmsg()
{
    var msg = "<?php echo $msg; ?>";
    if (msg) {
        alert(msg);
    }
}
checkmsg();

$(document).ready(function() {

    $("#search_btn").click(function () {
        $("#flag").val("search");
        $("#adminForm").attr('action', '<?php echo $html->url("/extra/extramgnt")?>');
        $("#adminForm").submit();
    });

    $("#update_btn").click(function () {
        $("#flag").val("update");
        $("#adminForm").attr('action', '<?php echo $html->url("/extra/extramgnt")?>');
        $("#adminForm").submit();
    });
    
});

/*function submitthis()
{
    var flag = document.getElementById('flag').value;
    switch (flag) {
        case "delete":
            var msg = "Are you sure you want to delete the selected ticket?";
            if (confirm(msg)) {
                document.adminForm.submit();
            }
        break;

        default:
            document.adminForm.submit();
        break;
    }
}*/
</script>